library(fars) library(dplyr) library(maps)
This vignette gives an overview of teh FARS package and the purpose of each function. Its functions analyze data from teh Fatality Analysis Reporting System (FARS) [[found here](http://www.nhtsa.gov/Data/Fatality-Analysis-Reporting-System-(FARS)]
There are three exported functions for users:
A brief description with examples will be provided for each function. The FARS data for the examples can be found in the package directory under teh '\extdta' folder.
The function fars_read()
reads data from a file path provided as an argument. It returns a tibble
with the loaded data:
filename <- system.file("extdata/accident_2013.csv.bz2", package = "fars") fars_read(filename)
The function fars_summarize_years()
takes a vector or list of years (numeric/integer values) as an argument and if the corresponding files with data are available, it returns a pivot table with number of accidents per year and month. The data files need to be located in the working directory.
setwd(system.file("extdata", package = "fars")) fars_summarize_years(2013:2015)
The last function available in the package, fars_map_state()
takes a state index and year as arguments and returns a plot of the state with accident locations. The state indices need to correspond available indeces from the data set. Here are some examples:
setwd(system.file("extdata", package = "fars")) fars_map_state(45, 2015)
The data files need to be located in the working directory
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.